package com.telrob.bytevm.instruct;

import java.util.List;

import com.telrob.bytevm.compile.Instruct;
import com.telrob.bytevm.compile.ReplaceCode;
import com.telrob.bytevm.utils.ToolUtils;
import com.telrob.bytevm.vm.Register;

public class DW implements Instruct{
	public boolean isPseudo(String opt) {
		return false;
	}
	@Override
	public boolean isComplie(String opt) {
		if("dw".equals(opt.toLowerCase())) {
			return true;
		}
		return false;
	}

	@Override
	public byte[] complie(String line,String[] param,int curretIndex,List<ReplaceCode>labelReplace) {
		byte[]data=new byte[(param.length-1)*2];
		for(int i=1;i<param.length;i++) {
			int number=ToolUtils.parseNum(param[i]);
			data[(i-1)*2]=(byte)(number&0xFF);
			data[(i-1)*2+1]=(byte)((number>>8)&0xFF);
		}
		return data;
	}

	@Override
	public int isRun(byte opt) {
		return -1;
	}

	@Override
	public void parseRun(Register R, byte opt, byte[] code) {
		
	}

}
